package com.pactera.madp.cp.mapper;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pactera.madp.cp.api.entity.WorkContactEmployeeEntity;
import com.pactera.madp.cp.api.vo.contactloss.SidebarNoCommunicationVO;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.Set;

public interface WorkContactEmployeeMapper extends BaseMapper<WorkContactEmployeeEntity> {

    Integer getReal(@Param("corpId") Integer corpId);

    Integer getRecord(@Param("corpId") Integer corpId);

    WorkContactEmployeeEntity getLatestRecord(@Param("corpId") Integer corpId, @Param("contactId") Integer contactId, @Param("employeeId") Integer employeeId);

    WorkContactEmployeeEntity getRelatedRecord(Integer contactId, Integer employeeId);

    List<WorkContactEmployeeEntity> getAllLossContact(@Param("endTime") String endTime,@Param("channelIds") List<String> channelIds,@Param("corpId") Integer corpId,@Param("employeeId") Integer employeeId);

    /**
     * 获取客户对应的企业标签
     *
     * @param corpId
     * @param contactId
     * @return
     */
    List<Map>  getContactById (@Param(value = "corpId") Integer corpId, @Param("contactId") Integer contactId);

    List<WorkContactEmployeeEntity> getAllLossContactByEmployee(@Param("endTime") String endTime,@Param("channelIds") List<String> channelIds,@Param("corpId") Integer corpId,@Param("employeeId") Integer employeeId);

    WorkContactEmployeeEntity getLatest(Integer contactId, Integer employeeId);

    List<WorkContactEmployeeEntity> getLossContact(@Param("corpId") Integer corpId,@Param("contactId") Integer contactId,@Param("employeeId") Integer employeeId);

    Integer getAddContact(Integer corpId, String localDate);

    Integer getStatistics(LocalDate date, Integer corpId);

    WorkContactEmployeeEntity getWorkContactEmployeeDel(@Param("corpId")Integer corpId,@Param("contactId")Integer contactId,@Param("employeeId")Integer employeeId);

    Integer getContactCountByContactTypeAndEmployeeIds(@Param("contactType") Integer contactType, @Param("employeeIds") Set<Integer> employeeIds, @Param("endTime") String endTime);

    SidebarNoCommunicationVO getContactEmployeeInfo(@Param("corpId")Integer corpId,@Param("contactId")Integer contactId,@Param("employeeId")Integer employeeId);

    Integer getEmployeeAddCount(@Param("employeeId") Integer employeeId,@Param("beginTime") String beginTime,@Param("endTime") String endTime);

    Integer getEmployeeOtherCount(@Param("employeeId") Integer employeeId,@Param("beginTime") String beginTime,@Param("endTime") String endTime);

    IPage<WorkContactEmployeeEntity> myPage(
            Page page,
            @Param("corpId") Integer corpId,
            @Param("channelIds") List<String> channelIds,
            @Param("startTime") String startTime,
            @Param("endTime") String endTime,
            @Param("employeeId") Integer empId
    );

    List<Map<String,Object>> getDistinctContactlistMaps(@Param("corpId") Integer corpId, @Param("tenantId") Integer tenantId, @Param("dateTime") DateTime dateTime);

    WorkContactEmployeeEntity getNewestRecordByContactIdAndEmployeeId(@Param("corpId") Integer corpId, @Param("contactId") Integer contactId, @Param("employeeId") Integer employeeId);

}
